package net.newsmth.smthapp.android.model;

import org.json.JSONException;
import org.json.JSONObject;

import java.io.Serializable;
import java.util.Date;

/**
 * Created by Hatsune Miku on 4/12/14.
 */
public class BBSThread implements Serializable {

    //region Static member
    private static String JSON_ID = "id";
    private static String JSON_AUTHOR_ID = "author_id";
    private static String JSON_TIME = "time";
    private static String JSON_COUNT = "count";
    private static String JSON_BOARD = "board";
    private static String JSON_SUBJECT = "subject";

    public static BBSThread convertFromJSON(JSONObject jsonObject) {
        BBSThread thread = new BBSThread();

        try {
            thread.setId(jsonObject.getLong(JSON_ID));
            thread.setSubject(jsonObject.getString(JSON_SUBJECT));
            thread.setCreatedTime(new Date(jsonObject.getLong(JSON_TIME)));
            thread.setCount(jsonObject.getLong(JSON_COUNT));
            thread.setBoard(jsonObject.getString(JSON_BOARD));
            thread.setSubject(jsonObject.getString(JSON_SUBJECT));
            thread.setAuthorId(jsonObject.getString(JSON_AUTHOR_ID));
        } catch (JSONException e) {
        }

        return thread;
    }
    //endregion


    //region fields
    private long id;
    private String authorId;
    private String subject;
    private Date createdTime;
    private long count;
    private String board;

    public String getAuthorId() {
        return authorId;
    }

    public void setAuthorId(String authorId) {
        this.authorId = authorId;
    }
    public Date getCreatedTime() {
        return createdTime;
    }

    public void setCreatedTime(Date createdTime) {
        this.createdTime = createdTime;
    }

    public long getCount() {
        return count;
    }

    public void setCount(long count) {
        this.count = count;
    }

    public String getBoard() {
        return board;
    }

    public void setBoard(String board) {
        this.board = board;
    }
//endregion

    public String getSubject() {
        return subject;
    }

    public void setSubject(String subject) {
        this.subject = subject;
    }

    public long getId() {
        return id;
    }

    public void setId(long id) {
        this.id = id;
    }


}
